<h1>产品列表</h1>

<table class="table table-striped table-bordered table-hover">
  <thead>
    <tr>
      <th>标题</th>
      <th>类别</th>
      <th>tags</th>
      <th>置顶</th>
      <th>相关文章</th>    
      <th colspan="3"></th>
    </tr>
  </thead>

  <tbody>
    <% @products.each do |product| %>
      <tr>
        <td><%= product.title %></td>
        <td><%= product.category %></td>
        <td><%= product.tags %></td>
        <td><%= product.top %></td>
        <td><%= product.articles.map{|article| link_to article.title, admin_article_path(article) }.join("<br/>").html_safe %></td>
        <td><%= link_to 'Show', admin_product_path(product) %></td>
        <td><%= link_to 'Edit', edit_admin_product_path(product) %></td>
        <td><%= link_to 'Destroy', admin_product_path(product), method: :delete, data: { confirm: 'Are you sure?' } %></td>
      </tr>
    <% end %>
  </tbody>
</table>
<%= paginate @products %>
<br>

<%= link_to 'New Product', new_admin_product_path %>
